package net.knightwatch.kwtools.database; 

import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class AddressTable {
	// Class Information
			private static final String TAG = "AddressTable";
			// Database Table
			public static final String TABLE_ADDRESS = "Addresses";
			public static final String COLUMN_ID = "_id";
			public static final String COLUMN_STREET = "street";
			public static final String COLUMN_CITY = "city";
			public static final String COLUMN_STATE = "state";
			public static final String COLUMN_ZIPCODE = "zipcode";
			public static final String COLUMN_COUNTRY = "country";
			public static final String COLUMN_CREATED = "created";
			
			// Database Creation SQL Statement
			private static final String DATABASE_CREATE = "create table " 
					+ TABLE_ADDRESS
					+ "("
					+ COLUMN_ID + " integer primary key autoincrement, "
					+ COLUMN_STREET + " text,"
					+ COLUMN_CITY + " text,"
					+ COLUMN_STATE + " text,"
					+ COLUMN_ZIPCODE + " text,"
					+ COLUMN_COUNTRY + " text,"
					+ COLUMN_CREATED + " datetime"
					+ ");";
			static final String[] ALL_COLUMNS = {COLUMN_ID, COLUMN_STREET, COLUMN_CITY, COLUMN_STATE, COLUMN_ZIPCODE, COLUMN_COUNTRY, COLUMN_CREATED};
			
			public static void onCreate(SQLiteDatabase database) {
					try {
						Log.i(TAG, "Creating " + TABLE_ADDRESS + " Table");
						database.execSQL(DATABASE_CREATE);
					} catch (SQLException e) {
						e.printStackTrace();
					} finally {
						Log.i(TAG, "Table " + TABLE_ADDRESS + " has been created");
					}
			}
			public static void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion){
				// Insert alter methods here to add new columns to the database.				
			}
}
